<?php
  require_once('tpl/header.php');
?><?php 
      require_once("loginCheckadmin.php");
      require_once("../system/dbConn.php");
 
     ?>
  <form action="">
    	<input type="text" name="key">
    	<input type="submit" value="搜索">
    </form>

 

	<?php 
	//连接数据库：读取users表中的所有记录，显示到表格中



	$sql = "select * from activity";
    
    if(isset($_GET["key"])){ 
       $key=trim($_GET["key"]);
       $sql="select * from activity where aname like '%{$key}%'";
    }
    
	$result = mysqli_query($link,$sql);
//结果集
	$num = mysqli_num_rows($result);
	if($num==0){
		echo "没有记录，请重新输入";
		exit();
	}
	?>
	<table class="table table-bordered" align="center" width="60%">
		<caption>活动信息列表（共 <?php echo $num ?> 个活动）</caption>
		<tr>
			<th width="10%">活动编号</th>
			<th width="25%">活动名</th>
			<th width="50%">活动详情</th>
			<th width="15%">操作</th>
		</tr>
	<?php
	while ($row = mysqli_fetch_assoc($result)) {
	?>
		<tr >
			<th ><?php echo $row["aid"]; ?></th>
			<th ><?php echo $row["aname"] ?></th>
			<th ><?php echo $row["adetial"] ?></th>
			<th ><a href="actEdit.php?aid=<?php echo $row["aid"];?>">修改</a> | <a href="doActDelete.php?aid=<?php echo $row["aid"];?>" 
				onclick="return confirm('真的删除吗?')">删除</a></th>
		</tr>
	<?php	
	}
	 	?>
		</table>
	</form>
   


<?php
  require_once('tpl/footer.php');
?>